//
//  SupportTableViewController.swift
//  quizDemo
//
//  Created by LiuXing on 2017/9/11.
//  Copyright © 2017年 quiz. All rights reserved.
//

import UIKit

private let reuseIdentifier1 = "ShopTableCell"
class SupportTableViewController: UITableViewController {
    
    var item: [String]! = ["question1",
                           "question2",
                           "question3",
                           "question4",
                           "question5",
                           "question6",
                           "question7",
                           "question8",
                           "question9",
                           "question10",
                           "question11",
                           "question12",
                           "question13"
    ]

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
        tableView.rowHeight = 44
        tableView.register(UINib.init(nibName: "ShopTableCell", bundle: nil), forCellReuseIdentifier: reuseIdentifier1)
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return item.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: reuseIdentifier1, for: indexPath) as! ShopTableCell
        cell.contentLabel?.text = item[indexPath.row]
        let red = CGFloat(arc4random()%256)/255.0
        let green = CGFloat(arc4random()%256)/255.0
        let blue = CGFloat(arc4random()%256)/255.0
        cell.leftView.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: 1.0)
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let vc = SupportDetailViewController()
        navigationController?.pushViewController(vc, animated: true)
    }

}
